let mysqlConnection = require("./mysqlConfig")
//let ManagerPojo = require("../models/ManagerPojo")
module.exports={
    selectManager : function(id) {
        return new Promise((resolve,reject) => {
            let selectManagerSQL = `select * from manager where id=${id}`;
            mysqlConnection.query(selectManagerSQL, function(error, results) {
                if (error) {
                    reject(error)
                }
                else {resolve(results);}
            })
        })


    },
    insertManager : function(ManagerModel) {
        return new Promise((resolve,reject) => {
            let insertManagerSQL = `INSERT INTO tasks.manager (id, fammily_name, given_name, sign_up_time, email, password) VALUES (${ManagerModel.id}, '${ManagerModel.fammily_name}', '${ManagerModel.given_name}', ${ManagerModel.sign_up_time}, '${ManagerModel.email}', '${ManagerModel.password}')`;
            mysqlConnection.query(insertManagerSQL, function (error, results) {
                if (error) {
                    reject(error)
                }
                else {resolve(results);}
            })
            })
    },
    updateManager:function (ManagerModel) {
        return new Promise((resolve,reject) => {
            let updateManagerSQL = `UPDATE tasks.manager t SET t.fammily_name = '${ManagerModel.fammily_name}', t.given_name = '${ManagerModel.given_name}', t.email = '${ManagerModel.email}', t.password = '${ManagerModel.password}' WHERE t.id = ${ManagerModel.id}`;
            mysqlConnection.query(updateManagerSQL, function (error, results) {
                if (error) {
                    reject(error)
                }
                else {resolve(results);}
            })
        })
    }
}